Removed excessive use of malloc().