Organizing my legacy code