Cleaned up curves.cpp, and added some comments.