fix math o.O
some more shifting optimisations