Add output interface and some fixes.