attempt to split code into cpp files. currently broken.