questionable patch: merge of a lot of stuff from the svg branch