Multiple bugfixes and enchansements