Refactor some utility modules