Made engine changes and fixed castling bugs