All the code is together

This integrates all the code together under the old main function; it
could be useful for seeing how everything fits together, Sam.