bugfixes, tracing, test cleanup