fixes several typos and adds partial support for BSD