Added PidFile class and cleaned up