Fix minor bugs and pep8

Change-Id: I22e44afa2fddaacf7d336012c2b9b0864de7ccf0