Fixes to memory usage issues, etc.