Add some comments and renamed a few functions.