Fixed memory leak and included comments for all files