parallel naive algorithm and several fixes.