Housekeeping tidy up.

Moving some functionality around and standardising namespaces and
formatting.