Separated out some functionality into separate classes