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.
Also, the aforementioned documentation seems to be wrong. It says the only values of ```type``` are ```["flag", "not flag", "all", "any", "not all", "none"]```, but below you also have a bunch of other cases.