No major changes, comments added, whitespace reduced