Lei: refactor image distributor and add cache to avoid login and reconnect every time