Added image url conversion, cleaned up code