fixed bugs with image loading....but code is somewhat ugly while i'm partway through