Improved EMD implementation

The first of the changes in EMD that are taken from Patrick Flandrin's
MATLAB toolbox.