Remove redis and refactor code.