mass refactoring: separate modules, add jsdoc, and cleanup async connect/configure