api cleanup and logging