patch castling bug