Various improvements and tidy-ups re. widget validation.