Fixed PuzzleCapture bug + efficient algorithm refactoring