Fixes for subtype-related bugs + regression tests.