Fixed bugs 20141008 and 20141009 from Gasperotti