Improvements and tweaks to parser