Support for single port mode

This implementation of single port mode is a big hack. Refactoring
needed!