Updated the code - more to come tomorrow

Need to rearrange some boxes but I've majorly condensed the code :)