Some changes and bugfixes