Add several type-safe property retrieval methods

This change makes the document class much easier to use, and the
resulting code much easier to read since a lot of manual type casts
are now avoided. It also enforced type safety in the code, and puts
the onus on the developer to make it clear what the type
expectations are.