Implement --pidfile

Also fix --envdir