Add gridTemplate util and fix misc