Converting metadata generator to using resolved AST.

Fixing some serialization issues with metadata generator.
Cleanup of unused code.