fix some units and a major bug with unit inversion