internal refactoring
code & pkgs fixing