Minor refactoring, removing code duplication, better names