fixed a few linux issues and better error checking