Put on jshint.
Refactor: extract state menagement.