Toddlers have to test and try things out over and over to see what will happen. It is how they learn. Unfortunately, they figure out what gets the attention (negative attention), and they keep doing it.
It sounds like you are doing lots of great things- giving him opportunities and places to hit and throw things, teaching him that hands are for gentle touches, etc. You should definitely keep doing these things!
You can try to ignore the undesirable behavior when he isn't in danger of hurting himself or someone else. It is difficult to do, but when he stops getting a reaction, he'll get bored and stop the behavior. Sometimes you literally have to turn your back so you are still close by but he can't see your face! And staying un-emotional helps, too. If he knows he can't get a rise out of you, it might not be as fun for him.
You could also have some things inside that he CAN hit- like spoons on pots and pans, or one of those toys that you hammer in the pegs. Then you can say things like "pegs are for hitting" instead of "don't hit ______." (Which you may not be saying, but the point is that you can give him ideas of what TO do, instead of what NOT to do...) You can also give him something that he can throw indoors, so when he starts throwing things, you can redirect him to things that are throw-able. Then you can say something like, "Blocks are for building, (help him stack them). Here are some ______ (balls?) that you can throw."
My favorite balls are those splash balls you use in the pool- made out of sponge, with a fabric layer on the outside (not a huge danger of him biting chunks out of the sponge unless the ball "rips".) They wont damage anything if he throws them and he can throw as hard as he wants! You can even give him something to throw the balls into or at.
Hope this helps- just know that he is a toddler, he is a boy, and these behaviors are pretty age-appropriate for him. Toddlers do these things to get a reaction, and not because they are "bad" or want to hurt people.