most of platt.cpp written