Small changes done to prepare threading