minor code tweaks and commenting