"Impure thoughts", "if i ever had masturbated"... This is a bit medieval, to say the least.
As for morality: it is not equal to the concept of sin. Some type of morality existed in all societies, whereas the concept of sin mentioned here is characteristically of the judaic tradition. Secondly it is a set of rules, for those who for whatever reason need rules so as to avoid acting in manners which would inevitably make them unpleasant to others. No sensitive person would agree with behaviors that would lead to hurting someone, but no logical person would seek a set of rules so as to avoid such an outcome of his actions.
The sexual drive, and also the sensitivity of the nerves to sexual arousal, is there for biological reasons. Man was not expected by anyone to be able to develop as complicated ways of thinking, and moreover from a biological viewpoint the ensuring of survival of the species (which happens by sex) is infinitely more important than anything else. This is why there had to be biological safelocks in place, to ensure that sex would remain to be seen as a goal. Enter the church, with its braindead views about anything, and now a pleasant human ability is seen as something to struggle against. However if one did not want to be involved with sex or masturbation he could decide not to; the dogma on the other hand is about enforcing a rule against it, and regulating it.
The reason for the support of such a regulation was/is the various fears, dissapointments, frustrations of those who come to accept it. Only that in reality that religiou stance was not created with them in mind, but just found someone of credentials to accept it by tricking himself into thinking that his own negative issues were prophesised of in a book of a historically backward and weak ancient culture.
It is no wonder that christianity found followers in the weak/poor/miserable/ill. They were sufficiently in despair by the time it reached them so as to view it as a final hope of managing to keep on living. Sadly this was just that: a final hope, and not a solution to what had lead to their state in the first place.