Move neighbors into one function
Move factory calls into resolve
Remove unused scopes