Simplify some ugly code.