Change image handling logic
Code cleanup