tweaks to upper/lower and misc removal of unused imports