Some architecture improvements and bugfixes