XDeriveFunctor and some cleanup