fixing mysql query and adding version information to cron orphaned files