Feature/document mapping

PR created on behalf of @bterkuile. Wanna take a look at this soon!