Fix for threading sync issues