Small improvments and bug fixes