code tweaks and more moved from USGSwsBase