Performance improvements

Stop calling _getElementDimensions all the time. These shouldn't change
so just set them at the start and reuse.