Changed every mutex.lock - mutex.unlock pair to ensure mutex release even with errors
closes #79