maxpq with links done, refactoring needed