Refactoring and commenting stuff