Fix index on mixed units error. Fixes #1228