clean, efficiency, cdn

Cleaned up some code.  Made some changes to make it more efficient.
Also, added support for CDN endpoints.