Moved allocation of memory for gaussians inside function where used