More type cleanup and explanatory comments.