I have done this plenty of time try this
what you will need
itunes -
Apple - iTunes - Everything you need to be entertained.(alternate method) sn0wbreeze -
iH8sn0w.com download snowbreeze
try ios 6 method if it does not work try other method on here
easier than main method (ios 6)
step 1. open itunes
step 2. hold down 3gs home button (do not sop til i say to) While stil holding home button plug it in to itunes do not let go
of home button until this appears
then let go of home button
step 3. itunes will detect it in recovery mode click on it and click restore
step 4. itunes do the rest
step 5. try next method if it did not get rid of bugs
main method (5.1.1)
step 1. open snow breeze and select download ipsw (do not use the link 5.1.1 that is for something else if this does not work)
step 2. do all options and let it finish
step 3. you should have a file like this example5.1.1.ipsw
step 4. open itunes
step 5. hold home button on 3gs then plug it in still holding home button do not let go until something shows up on screen saying to restore with itunes
step 6. click on device in itunes press shift(command for mac) and press restore with out letting go of shift(command for mac)
step 7. you should have a window popped up from step 6 locate ipsw file like in step 3 and click it
step 8. itunes will do the rest if problems private message me