various fixes from Quartz implementation, including Firefox compatibility