PY3 apply() fixes

apply() doesn't exist in PY3