fixed compilation on gcc, sped up curve unit tests, further cleaned up the code.