Based on Trilu's patch http://forum.xda-developers.com/showthread.php?t=1007774
Removed some debug and unnecessary code, and added some missing code by tytung.
Thanks to Trilu for finally fixing the BT problem.
Thanks to Charansingh for the work he has done on the BT problem.