Added some extra functions and comments.