Added portal reading and server thread termination.