Adding validation.
Cleaning up code.