pruned and grafted the refactored compiler from the metadata branch. Tests run, but code needs cleanup