initial plan structure, and some misc fixes