Code style and related minor performance optimizations