Somewhat fixed priv.cpp, still needs further changes