Fixed small performance flaw in NamingParent.
Created QueryBuilder to generate SQL queries.