Some code fixes and code formatting have been applied.