Add lock file and timeout support

Close #6