Here's how it looks with the suggested modifications. Whatever compiler wonkiness I was seeing is gone now, so I've used the most straightforward version of the shifts.