Split out source, header, and main()

I want to use this code in another project, so I made a few changes to make this easier.