Correcting image loading
Some refactoring