Organizing functions and cleaning up