break out some files, add pidfile support