Improving memory usage
Updated tests