Finished code organization

Put things where you would logically expect them to find them and added
lots of nice explanatory comments.