Refactored code layout to make it generic cross platform. Added some further code ideas. Needs more work, won't currently compile