refactor into files; remove namespace std