Protect parts of interpreter with mutexes for thread-safety