Draft implementation of multi-directory support

This implements IPEP 16. There is still a lot left to do to reach our final goal. It's not ready for merge.