Improved code for finding moves. Closes #5