Fixed divide-by-zero error and possible lack of float issue.