Issue #1439: Make extend option to overwrite in the right direction

Signed-off-by: Anton Kovalyov <anton@kovalyov.net>