Pidfile handling

Some fixes for #16