Tidy up and minor structure change

changed the data structures to allow for future changes
Removed redundant code in script