Added systematics evaluation.
Fixed bug in resampling.
Some cleanup.