Some fixes and improments