Fixed bug in castling logic.