Fix some integer overflows and a stupid memset() invocation