added additional comments and fixed some formatting.