Modified syntax to default to global scope.
Added max check to prevent trying to sleep for a negative amount of time.
Other minor changes.