Clean

* Remove spaces.
* Remove unnecessary cast.
* Refactoring some functions.