Code reorganisation for entity limits