Fixed some check return for error allocating memory and thread creation. Fixes #35.