Updated from atm foundation fork