Some more fixes

As I just said, here's an update to the previous pull request. Please check if the demo project still works ok, at least for me it does.