Refactor Libffi and RTS rules