Fix direction variables.
Use strict mode.
Refactoring.