Small improvements and little changes to threading