Fixed massive bug that meant things only ever worked by chance
Fixed flycheck warnings