tweaked some errors in the control script and moved the socket listener to lib