math utils; some cleanup