Minor refactoring, which will allow us to parse the database instead if desired.