Integration tests and bugfixes