Add some comments, fix a bug