Changes after code review. Cleaning up names as well.
Adding comments to functions.