added support for summing multiple gaussian kernels
added some failsafes in R-code to avoid segfaults