Some bugfixing. May need -lrt flag.