Refactoring, preparing for ds heuristic