use a hashtable for attachment position lookups (faster than the fugly loop)