break into seperate files, some cleanup