fix status checking and pid file creation