cleanups and fix invalid start_document function signature warning in document.c