Some refactoring of ContentManager based on work by hyanwong