Major efficiency and memory improvements