Code refinement and minor updates to comments