added weighted resampling and trimmed keyval sizes
closes #30