First draft of type handler code

no tests yet, not enough docs, and probably doesn't work yet/