Added Some Comments and Structuring

Additional Comments were added and some restructuring of the code was
done to improve readability