Reformats, more informative error if you mistype

Reformats sources to be more consistent, throws an informative error if you mistype, simplifies implementation a bit.