Fix whiplash algorithm when using goals

Use all_completed_count instead of completed_count to take goal completions into account. Sorry about all of the seemingly extraneous changes but my editor config removes extra whitespace and adds a linebreak at the end.