Extracted mongo into own module. Also rewrote parts that enable composition of conversion functions