big refactor, exposed events, separated nodejs use from cli