Curves code moved to a separate file