Implement mergesort. Small bugfixes