Add mean and middle data calculation. Draft. No sql.