Use $includes array for settings references

It now uses the includes array to set the references. I also added a test.