refactored the resource loading functions. each function is now side-effect free (doesn't change any outside data)