Bug fixes for crashes and memory handling.