General refactor