If you will be working in close quarters attaching new molding to walls or ceilings with finishing nails, first check out your hammer handle. Inevitably the handle end will hit the adjacent surface in spots. Either use a new hammer, clean up the handle of an older hammer, or mask the end of the handle with masking tape, especially if the handle has an older covering of black rubberized material. Doing this before you start can save you time that otherwise would be spent cleaning up or repainting over the scuff marks.
Bent nails often result from poor hammering technique. However, they can also be caused by a dirty hammer face, especially when using cement-coated nails or working around adhesives. If you have problems, occasionally run a piece of fine sandpaper or emery cloth over the face. If you keep the face clean you will gain more solid contact with the nail and will avoid black marks on the wood caused by a dirty hammer.