More safety-proofing for UI input.
merging with master