Fixes to function on CentOS 6