Moved some stuff that will be common to various parts of the application into separate files.