Restructuring framework.cpp for new usage