Shaper and hash function optimizations

I noticed these optimization possibilities while staring at callgrind output. The shaper can be quite a bit faster with this.