Further progress, horribly unrefactored now
No crashes, not working, refactoring!