Rewriting of proposal algorithm, which runs pretty fast now.