Improve error handling.
Fix bug, was locking the program instead of the lockfile.