Variables refactoring and dt correction. Warning: maxHeight must be investigated