Refactor metridoc main