added term partial and cleaned up formatting and comments