add type declartions, and improvements to the parser