Add proper figure handling to examples and to script