Reformatted for consistency using newer coding standards