Make toCore monadic: still has some unhandled errors, but they're going to go away soon