More malloc cleanup

Simplify functions to remove use of mallocs (and simplification)
Still more malloc's on this file to go...