refactoring, util method registerAndExecute now has optional condition

Change-Id: I479c71171e7a960a1c367676c8340fcf513fefff
added some code comments

Change-Id: I5ca5ab418b9cbdb3695adff71c973af27586fc47
refactoring, added nest and iterate util functions, used by prox detector

Change-Id: I3ec8f0ce2b5791f8deb355e912585cbe1bb03518