Reworked grid layout to work faster.