Refactor/move code, builds completely clean now, added lots of features (untested)