Fix several problems