Rearranged branching for better logic flow.

Added comments and did my preferred branching.