Bug fix & improvement

Fixed bug & added commandline improvement (by codelover @
http://forum.xda-developers.com/showpost.php?p=49059451&postcount=15 )