added macro to do runtime checks (no matter if release or debug)
added runtime checks to avoid invalid models
some python changes