If you've been riding it around with a really loose headset and it's not a sealed bearing type, you could be missing some of the balls / rollers that make up the bearing - this might explain the weird steering symptoms you describe. If you decide to check this, take the top cap off completely and remove the stem. You should then be able to slide the fork out a little and see what's going on inside. If everything looks like it's there and covered in grease (not mud), reassemble and do the whole thing up like Malaysian said. If it looks like any balls / rollers are missing or it's full of mud, then you need to google "headset servicing".
If you've been riding it around with a really loose headset and it's not a sealed bearing type, you could be missing some of the balls / rollers that make up the bearing - this might explain the weird steering symptoms you describe. If you decide to check this, take the top cap off completely and remove the stem. You should then be able to slide the fork out a little and see what's going on inside. If everything looks like it's there and covered in grease (not mud), reassemble and do the whole thing up like Malaysian said. If it looks like any balls / rollers are missing or it's full of mud, then you need to google "headset servicing".