cleanup and refactoring to use cleanupOnWordBoundary for removing items