Improved PID Lock File Handling

This pull request should close #135 and fix other issues with handling the pid lock file on startup.  

(This also closes #160)