move ivars to attrs and move server stop logic into server_stop method