ApproximationDemo: optimizations, tweaks, generalizations