Refactoring and added curveplot demo.