Apply $last to the array after properties starting with $ have been filtered out

Fixes #1789