fix null pointer exception, add more comments.