Significantly simplify util code