Added dictionary parsing, restructured code