More cleanup. Moved Metrics to its own package.
Still more cleanup
Yet more cleanup
Update getTypeId to getType where possible
A few more small fixes.