Some bugfixes

Some bugfixes

fix NullPointerException during getting optional parameters
fix IOException during reading socket stream