Code cleanup
Fixed build for Linux, FreeBSD and Mac