refactored connection and command classes