Removing closing PHP tag
Minor code formatting (e.g. one line if/foreach statements)
Adding function comments and minor code formatting.