Refactored quite a bit of code structure in preparation for type_traits.

Change-Id: Ifed309b3ecff9e7ebb627ea1296ffa4ff707a84c
Reviewed-on: http://www.matthewh.me/gerrit/35
Reviewed-by: Matthew Hoggan <mehoggan@gmail.com>
Tested-by: Matthew Hoggan <mehoggan@gmail.com>