Added more comments for clarity.