Pull request 102 lps 32932

Hey Peter,

Can you review this one.
I changed the code a bit, but think most of it shouldn't really change any logic.

You can send to Brian if you're OK with it...

Thanks,

Hugo