grips-css: lots of refactoring to fix various parser bugs