Syntax fixes

Fixed syntax errors...
Optimizations; bracketed script waking

Optimized code, especially 300 processing; bracketed script wake
and sleep.
Bracketed Script wake and sleep

Waking scripts takes a long time; sleeping scripts can cause
scripts to miss settings and other things. Bracketed with WAKESCRIPT.