Fix for the race condition paulej72 described in #136.