Minor design rework, some bug fixes