Fix scheduler.

Also, minor style improvements.