Refactored NPuzzle.