Cleaing up p3d legacy code