Added comments. Checked for Bugs.