Fixes some bugs, cleans the API and code, adds more flexibility to the configuration, updated the demo project

I've split different tasks into separate commits so that it's clearer.

You should run your own tests before merging, I have only tested on Windows.

Let me know if everything I've done is ok for you, or if you'd like me to change something.