Fixed some bugs and implemented socket exception handling