Refactor setting configuration variables
Refactor functions sequence + fix code comments