WIP: of_type impl

closes #7316
yeah the implementation is a bit unreadable right now ... i'm working on it