clean up
added debug output + performance trick