lib: misc consistency fixes
lib: use "extend" npm module

Remove the inlined `merge()` function since that's no longer necessary