5.1 compatibility + small fixes