added daemonisation code, needs reworking on a computer that isn't my work mac