Moved initialization and cleanup functions to main.cpp