More metadata support and lots of other refactoring/redesign stuff.