a lot of refactoring for q4m/redis