Optimize entities