Added comments and tweaks.