Fixed bug in chunked writes. Added getn to deque implementation.