refactor: Move chunks of code into relevant includes

BROKEN at the moment. Needs index on mongo collection.