debugged failed asserts+divide by zero

failed asserts due to C's abs returning int (need fabs)
divide by zero caused by same problem.