Updated with new query code, template styles.