Fixed multiple button presses problem and fixed socket error when
closing