Bug fixes + regression tests