lot of fixes in math