3rd commit

Fixed some bugs in the first solution, should be ready now. Just need to
provide some proper output formatting.