Lotto: clean code and rule layer refactor