BUG: Prevent division by zero. Closes #650.