fix: should release function reference.
fix: should release references on failure.