added a new helper function for particle resampling.  Also added some better header comments to some of the functions