Bug fixes for 3.1