Added logging to the entire code base, fixed some comments and some function names.