Rework core API

Remove MonadIO, add tests, cleanup, etc