More optimizations to pr/9