Added intermediate buffer. Still understanding what's happening under the hood.