added sampling helper; some minor fixes