add comments; cleanup code