Added gethostbyname, fixed a few bugs and rearranged a bit

Hey,
I've been playing with the tinyhci stack for our new iot boards that use the CC3000 and found it to be much more reliable than the TI stack. I'd like to contribute to your work by submitting our patches. Feel free to take what you need and/or modify as required. 
Thanks
/Pontus