Adapted to newest libraries