various fixes/refactoring, started on Atom parser