bugfixes and modification of examples to test the fixes