Implemented scheduler. Not tested yet.