Several changes.

- Standardise error codes
- Do not delete lockfile when compromised