some general optimizations