commented some pieces of code + small refactorings