bug 1138: added comments to functions, fixed typo