Another memory fix (special thanks to jasoncatchpole)