added more comments; fixed a few problems created by previous code clensing