Lots of commenting added to the resources namespace, because some of the coding is subtle.