fix and other little optimization

Change-Id: I22e3f44dfe9ec52a7c64a41f52b0b91e741c833c