Move files to folders

Reformat code.
Improve validation.