Some cleanup and fixes for parser