Minor improvements

- Add exception handling for out of memory error