Refactroring and fix some style