Added nif functions
Added main nif functions