Serveral improvements, bugfixes