Feature/stat ellipse

Basically #878, but merged commits from master.