integration of various fixes from Sandro