Factored out entities controller functionality.