Adding output modes and fixing bug.