Various fixes and improvements to class flags

Fixes a couple of bugs (resolves #1211), adds class flag creation/modification time and scheduling status (resolves #1137), and improves query performance.
It might make more sense if this file were located in ```esp/public/media/scripts/program/modules/```, perhaps even ```esp/public/media/scripts/program/modules/classflagmodule/```.