and hopefully added saner error reporting.
Fixed braces, first try fixing mac compilation and removed useless NULL comparison.