Got the code to a working state. Marked the three lines that appeared to be breaking everything