Bug fixes for automatic upgrade