Added some small memory tuning and memory debugging