Better error checking in modules