Too many bicyclists try to ride as far out of the traffic stream as possible. This makes you much more vulnerable to hazards such as debris, potholes, suddenly opening car doors, turning cars, and cars/trucks passing too closely. Prevent all of these by being visible and claiming your position in the lane to discourage unsafe driver behavior. Take the lane whenever you need it. Car drivers don't feel bad about taking the lane for themselves, and you shouldn't either. See Bicycle Safe for more tips.
For what it's worth, bus drivers are also taught to take the lane in certain situations to discourage or prevent unsafe driving practices by others (i.e. when a lane is too narrow for a bus, or when periodic hazards are present in the right lane).