performance improvement and fixes (#6394)
### Description
some small performance improvements
and
a little fix where collectibles are not removed when a task becomes
dirty during execution
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->