Some more tests and performance improvements