Moving some code to new files to ease development