Puzzle refactoring. Fix potential npd. Work toward #12.