Cleaned up attribute extraction code