Small speedups

Here are some small speedups and better form (well, my preferred form). The malloc/memset -> calloc changed is preferred in other projects too (e.g. OpenBSD).