Fixed checkmate code (mostly)