Complete refactor of doc system