Implemented first draft of solving the puzzle. Fixed bugs.