simplifications, tweaks, and test code