Code tweaks and commenting