prepare prototype and a few other fixes