Renamed collapse(d) to close(d).  Further enhancements and fixes.