mutexed initialization added, fixed some for loops