Cleanups and optimization

a028c717332f366fdff70bda66dc420eee2dcffa removes some `base_uint` reverse iterators which are unused and broken and removes yet another impementation of a "hex character to corresponding integer". 

**Important**: Please note that this patch changes the behavior of `base_uint::SetHexExact`: previously the function happily acepted non-hex characters and returned some kind of mangled `base_uint`. Now, the function will return `false` when encountering invalid characters. The `base_uint` is left in an unspecified state.

b35eabe161987cd7fefc0dee6480946aeb50d714 may seem a trivial change but it should make a difference when we write ledgers out to the database:
* We memoize conversions of arguments to strings, reducing the number of times we call expensive functions by *at least* 50%. 
* We call `std::string::reserve` to preallocate the buffer we need instead of requiring potentially expensive resizes.

On the non-performance front, change some loops to use C++11 ranged `for` and use `auto` for certain types.