Reduced memory usage. Fixed unexpected hang ups.