Some code refactorments