Comments added. Functions reorganization. Cosmetic fix. #7