Made a test file and implemented many of the suggestions made by James