Implemented downsampling. Call functions are now in a new file.