Fixes bug in missing resources scheduling check

Avoids IndexError that occurs when a class is not yet scheduled.

Also increases the performance of that scheduling check by moving some
calculations out of a for-loop.