Moved image handling further down to avoid required whitespaces chopped of