changed port and cleaned up code