Switch to using lodash, small bug fixes