Fixed locking bug
Now pids are recorded in lockfiles, so they can be checked later. If there is a lockfile, the pid is checked and if it is still running it prints an error and quits, otherwise it deletes the lock