some performance optimizations (nicely suggested by VS/CLR profiler)