speedup, benchmark, debugging code
minor refactorings