Code clear and bug fix

Remove unused code. Clear code style. And fix a bug ;-)