CSPACE-5988: More code cleanup, and add some comments.