Code refactor and comments

Some code refactor and comments to assist in understanding what's taking place in the code within the app