Move parser factory decorator into parse.py. Fix multiple bugs in parse.