Some refactoring

Change-Id: I557766aef824594a0bb57794ddfd5bef5cf49e8c