Code Tweaks

More code tweaks and improvements.