some cleanup and add the first bits for a real template