big core refactoring, added writeln/1