Fixed minor threading issue (thanks @jacobvo)