Moved schedule code into a new reusable file.