Refactor image handling
Refactor image handling