added lazy function for theil + minor fixes