//Cleaned some code and fixed checkmate checking