Moved code into separate files