added comments + some code clean-up