Complete re-write as (pseudo)daemon

Complete re-write of script that will no longer require a cron with much delay, but now can be run as a (sort of) daemon, or at least a back-ground process. May get round to adding actual daemon code at a later date.