bug fixes; improved image handling