PID file handling and better error messages