moved code to separate files a bit, small tweaks to try and get things working