Changed to using flock for locking
Deleted missed line from old pid locking
commented out old lockfile line
Set the lockfile name after the script name itself
Minimal refactoring