several fixes thx to kylon

Change-Id: If2e9910f4855cf0744ddcbefc27726339b9f557f