sync with draw elements improvements branch