some performance optimizations (hopefully)