Check that arrays aren't empty before creating resources.  Fix silly typos.