Fix several issues with division