Fixes bug in handling empty arrays and non-object input