Modified script to use dictionaries for storage.