Various improvements + more tests