Fixed openDocument, improved logging