Update to support nested files properly

This works for most cases.