fixed various bugs, appears to be working now
TODO: more thorough testing of correctness
TODO: clean up files, including imporoving documentation/commenting, etc
TODO: investigate logic of parser, and sources of conflicts, and whether
    these are an issue