Fixed output stream flush bug and parameterized port