Fixed port type (must be int) and exception handling