Added +1 to malloc calls