Check A and B against zero

Also include Danny's improvements.