applied fixes/modification from http://www.ip-phone-forum.de/showthread.php?t=267477&page=3&p=2028714&viewfull=1#post2028714