added some comments, did some refactoring

Change-Id: I69ebdcad9cc3e97280c7d89222620c66e8169bbc