JSHint + Bugfix

This code seemed like it couldn't work as advertised; appending any resourcePath would not work.

The code was a bit dense, so I took some time to JSHint it and clean it up for readability. It's not perfect, but should get the job done for now.