Interface definition and major refactoring.

There are a LOT of changes, as you can see. 
I guess you will just have to put your trust in me that it works! :-)
I have merged my changes carefully with your latest commits and made sure that it works smoothly.
You will need to accept my version of each file when it comes to handling all the merge conflicts. 
Because manual merging will be extremely difficult; I suggest you avoid that path.