Added some comments
Small code reorganizations