Style changes; add some comments; small bugfixes