Replace some deprecated functions and small fixes