Add comments.
Compact code.
Use reliable Redis UP check and remove redundant and deprecated variables.