Refactor code to remove dependency on HC 4.2