Various fixes

Sorry that it is just two big commits...

Changes released under the MIT license.
This should probably not be commented out.

Also, I'm not sure replacing all printf's with g_warning is a good approach, is there a reason why this is required?