Merge pull request #1823 from fdlk/master

Improve formatting and fix validation of input elements