Core bugfixes and improvments