Moved reusable code to separate packages so they can be shared between cron job and web service.