Code optimizations. More groundwork for the checkmate algorithm.