several minor fixes proposed by Andrey