Fix Mem Leak and other small fixes.