fixed resource management and dealing with stopping threads (try ctrl+D on server). Also cleaned up Eclipse warnings