Lots of improvements (unstable commit)
more restructuring and improvements
Almost finished refactoring, just a little bit more code