Add debug log, minor bugfix