Cleaned up some parser and math code