minor bugfixes and debug flag