Some improvements

 * Remove unused struct elements
 * Rename some things
 * Reuse more code
 * Use 512 byte read buffer
 * Remove ReplaceCallback() function