MDS fixes and general cleanup