Major refactoring of variables names and usage