fixes permission bug.
added protection against a little exploit to bypass keys.
fixes lot of issues with the scheduler.
made a few things more fail proof.