Fixes for java viewer listen mode, TcpSocket methods, and code cleanup