Stuff for beginning and end of documents was duplicated in the preamble. Fixed.

Signed-off-by: Thomas Hodgson <thomas.hodgson@gmail.com>