fix ifdef hell and redundant imports

also import Typeable.