Use a wrapper around malloc() to check for errors, fix bug in index handling when loading models containing points and lines