Misc optimizations.

This could be done by blockhash() instead, so that people using this as a library doesn't have to figure out which total function to use.