Cleaned code to mallocs standards, changed to sqrt from vectorLength.