refactoring, prepping for server mode