Refactor puzzle solving to improve performance on regular clicks