Moved IO output into main library, fixed several minor issues.