Improve previous commit and make it compile (hopefully)
Change the previous solution slightly to feed into GCC's optimizer better.