optimizations, see #2