Added documentation to the file.

Without comments, going through this file is slightly hard for an amateur python programmer!