clean up, bugs

speed max, divide by zero