Added a preliminary sort of moves.
Debugging also a bit smarter.
Massive commit because I don't have time.