Fixes for memory leaks - possibly temporary solutions.