directories refactoring, matrix generation, h_ and or_ function review, matrix validation, fix problems