Final merging

My final pull request.
Code ist cleaned up and commented (at least a bit)