Refactorized some stuff