Add support for appearance streams in annotations

This PR is based off of PR #2507. It addresses the comments in #2507 and fixes some bugs.