Added some comments and re-arranged stuff