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

Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
Issue #1449: Replace for..in loops with forEach where appropriate
Issue #1451: Fix a regression caused by #1388
Issue #1123: Make checks for generator functions without yield optional