Solves some of parsing bugs, however, it is incomplete

FIXME