Link against -lrt locally
Fix some memory leaks