Andrey's fixes