Updated attribute and attribute value SELECT statements.
Minor refactoring.