Added comments and a few other functions