Test schedule

Code cleanup and bug fix.