Simplify Error Handling

I have simplified error handling in cases where malloc failed by using perror. All errors will now be sent to the error stream.