Big fixes and comments; still untested alpha version