fixes rm bug, improves dom traversal