Partial port of this - http://forum.xda-developers.com/showthread.php?t=2634743