Few improvements and bugfixes