Fixes from the last commit which was making the processing very slow