Small improvements and bug fixing