Compilation fixes by Andrey Berman