add prolog to packages
more custom functions and rearrange init to load functions early