Adding pidfile functionality