Refine code
Add port support