Fixed last two bugs from Gasperotti