Changed nomenclature, some structure, and lots of comments