UDID fix and some warning fixes

Check it out, the code has not fully tested but I'm using it on a production app.

Regards