Added a few safety-checks, as well as some new functions/fields to
help a program discover if it is being called from within a schedule.