Rewrite as classes and add pkg