Throw errors instead of printing them.
refactor image lookup code.