Added basic multithreaded protection