Merge discrete lib1

Just few edits.

I'm basing simplified DiscreteLib version on it, because the full one is way to complex for me to understand.