Warnings and memory leaks fixed.