Improved ATB variable code and fixed persistence bug