Added some safechecks to the system so that contracts don't blow up