Abstract over MonadIO

This (besides some cleanup) makes all generated functions generalized on `MonadIO` -- shouldn't have any overhead by itself because functions are inlined.