Added some comments and exceptions.