comments and moving prominent functions closer to top for readability