Fix a bug reported and some more tweaks.