changed response handling for erlang calls
code cleanup
reuse common code