Refactoring

Refactoring some methods.