Further refactoring of origin_calculator