use array_replace_recursive, luke

also fix #667