fix ifdef hell and redundant imports

commit a54ba0cb911b00eea3959f7297881b3ea06bafbd introduces an `#if` but no `#endif`. i'm pretty sure that breaks build for older , but i can't really test because i have the right ghc version.

also there were many redundant imports. cleanup that mess.

i also couldnt compile it without importing `Typeable`. I am not sure how it worked before.