more work on layout

some enhancements and corrects to math functions