Some fixes and EMD functions.