Improving the resample phase of the particle filter. Also added handling
for the exception case when the particles have zero probability