Reformatted code and added ability to pass in additional classes and selectors to be applied before rendering.