Moved logic into separate files, updated lo script