Added code from Fenix repository