Added dictionary, cleaned up code.