Added clean_session task to run periodically.
Made cleanup session task less vulnerable to high memory consumption.