Adapted to newest libs