fix some typos and init order bugs