fully working and tested. High memory usage.