Add several checks to prevent division by zero (triggered by converting ...

There are a few places where division by zero occurs when converting black.  Added checks to prevent this.