Make chaining behave as documented

Fixes issue #2.

I also got rid of trailing whitespace. Compare with ?w=1 to only see actual code changes.