Changed order of files
Improved code (e.g. checking for malloc error)