Fixes multithreading issue.