misc fixes
misc arithmetic fixes and improvements