import updates from ivans's code

Change-Id: Ib6841a17d60bfb076866a3a6d648a66d4407d1ba