Minor refactoring + comments