Added functions to clean up the code.