fixed cron gain bugs
misc code cleanup