typo
first stab at content type dispatch
remove repeat lookups

premature optimisation but it was annoying me
more optimisation (also removes some silly bugs)