Add comments and move redis condition where necessary