Some code tweaks as suggested