Variable dec and some refactorings.