some debugging additions and misc fixes