Please make sure to free the memory allocated to mask and its members. Valgrind is giving me leaks. It's good to see that there are no leaks within the rt_* functions themselves though.