Code design tweaks and improvements