Memory optimizations

Use smaller sized arrays when possible.