Miscellaneous changes

Cleaning code up so I can get it ready to support multiple files.