various bug fixes

Change-Id: I5fe12f4b09947a392ff7cac11c9d4eb14fd17447