Did a tonne of debugging. Stuff almost works now