Added support for absolute path images and refactored a little