some performance improvements

See individual commits for unit changes