code cleanup: edit to previous commit,
make 2d checks closer match 3d curve.
style cleanup: sizeof foo --> sizeof(foo)