Fixed a bug with the lock file.

The lock was created in a place requiring high permissions, resulting in potentially incorrect behaviour of the program.
Removed some useless debug lines