Added borders for clarification, rearranged some formulae