Architecture and minor fixes