Removed loops for buffer writing in favor of the much faster duplicate and put method.