reorganized and cleaned up unit conversion

It's definitely better now, but there are probably still issues.