more bug fixes with simplification involving division