fixed bugs and 'finished' malloc, memory allocation should work now
working on free