Lots of bugfixes and refactoring
x
Removed junk files