Bug fixes from Guillaume