Some restructuring and comment headers added