Fix bugs that affected initialization on first startup