Massively refactoring for a cleaner API.