added a few more tweaks and consolidation