Added ClassTags to some generic methods to enforce type consistency.