Merging upstream

Merging changes from upstream, removing dependency on libffi