More formatting and minimal code changes

Updating formatting for better readability and understanding,
and changed a few code entries for less memory usage and less
confusion.