Added scheduler. Fixed minor issues.