Refactor, validation.
Bugs fixed.