Added some comments and some new functions