debugging plus performance improvements