Fixed up some ugly code.