Cleaner 'insertDoc' implementation
- use Map fold functions instead of toList
- rename functions
- add comments