Second pass at using an API for spec references.

This should be more robust. Please do give it a spin before you blindly push it. ;)