Added p_temp and made necessary changes
Improved p_loaded to detect any loaded package