simplify apply, keys, values; fix 5.3 support