Add strict checks to code.

I  run you code on Tizen device and get strange messages... Tus I add more checks for your code to get better understanding what has happened.