optimisations and fix for parallel case