Improved separation of environment, directive parsing, pre and post processing.
Cleaning up unused imports and syntax issues