Only allocate the needed memory
Always initialize finalweight to 0