Other small bug fixes (thanks to Marco Chiarandini)