Fix race and leak

Sorry for submitting two commits in this pull request, but the second builds on the first.
what is ```debrelease -c```?
could you please check this option with different OSes, such as ubuntu 14.04, 12.04 and debian 7