Fixed some issues after rewrite.
Rewrote parser and normalization as well as tests.