Refactoring

File and record deleting now extracted to seperate method.
Refectored deleting so now supports multiple levels of source files

also improved heartbeat manager
HeartbeatManager will now only allow multiple registrations from the same
thread.
Refectored so that different threads now get new database connections.

Still need to sort out getting locks with the heartbeat manager on new
file records as they are created. This has partly been done in this commit
but is unfinished. See TODOs
updated heartbeat manager so it should not be possible for 2 instances to
pick up the same job
finished updates so can run distributed accross servers and handle errors
Fixes and servers now allocated id so they have their own working dir
Merge pull request #20 from LA1TV/master

Upgrade so can run distributed and files will only be processed on one server at a time.