Cleaned code, no functional changes.
Strengthen validation