First proper commit, plugin is in a partially working state and there is a lot of debug output at the moment (though still not enough)