Changes and other functions adapted