Fixed memory leaks - removed compiler warnings