Refactor core for better error handling

PR'ing so we can better comment.

First of all this is looking pretty nifty.
Actually, it's more "not solved problem", I was tired yesterday evening and forgot about this. The idea here is we need to instanciate an `Environment` object (as in the default export) if we're not given an `Environment` instance. I'll do this today, basically I need an helper function.