Check count of arguments before referencing them

Got segfaults here.