Fixed decimate function - Better solution has still to be found. Casting size to int is a dirty hack