Merging changes from MLstate