Factored common stuff out to included files to keep the main file cleaner.