Attempt to refactor image stuff.