Fix FreeBSD error and remove unused vars