Change all prints to elog, refactor