Rearranged structure, added comments