Added framework for multithreading in c files. Fixed potential memory leak in mlg.filter.