some speedup improvements