Fixes for annotations bugs.

This supersedes and renders irrelevant #1802.