Fixed image display bug.
Refactoring.