docman: clean, remove unused code & better check