Refactored APT. Untested.