big refactor, rename lib -> pkg, split pkg in subdirectories