plugged some memory leaks.
Changed the formatting in some files.