Added checking main thread for null
Merge branch 'master' of https://github.com/pc-mist/HalfAwake.git