Bug fixes from M.Kowalski