major refactoring, parallel bug fixedwq