Some final cleanup, adding comments for clarity