Minor code tweaks and commenting