Added Connection::useMaster() and refactored code.
Implemented master balancing.