Improvements to likelihood weighting and general importance sampling

Fixes #203, #202, #199, #196, #60