modularized cleaning functions, added matplotlib visualization