Small code reorganization.
Added comments.