fixes from Anatoliy Belsky