Bug fix and memory savings