Cleaned up code. Dictionaries everywhere!