cleaned a lot of the code: issues - strangely big memory use + lines