Refactoring and commenting AutoPortPlacement module