Tidied up file

Removed unneeded lines, renamed some functions to be more clear