function calls and some cleanup