See understand this whenever you are moving along the direction of current, you are actually moving along a drop in potential. If in moving along a closed path you find a resistance, check whether you are moving along the current. If its so, you have a term -iR in your KVL equation. If you are moving opposite to the current, you have iR. For a capacitor if you encounter the +ve plate first write -q/C. If you encounter the negative plate first write q/C.