Minor reoganising and commenting.