Added scheduler. Fixed some bugs here and there.
Fixed some bugs here and there.